package m2team.com.zuatet.game;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import android.R.integer;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import m2team.com.zuatet.R;

public class CustomGridMemoryAdapter extends BaseAdapter {
	Context context;
	List<Integer> lstNumber;
	int type;

	public CustomGridMemoryAdapter(Context c, List<Integer> lstNumber, int type) {
		context = c;
		this.type = type;
		this.lstNumber = lstNumber;
		Collections.shuffle(lstNumber);
	}

	public void notifyDataChange() {
		if (lstNumber != null)
			Collections.shuffle(lstNumber);
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return lstNumber.size();
	}

	@Override
	public Integer getItem(int position) {
		return lstNumber.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		ViewHolder holder;
		if (view == null) {// if current item is not showing --> must re-init it
			LayoutInflater inflater = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.grid_memory_item, parent,
					false);
			holder = new ViewHolder();
			holder.image = (ImageView) view.findViewById(R.id.memory_item_ans);
		} else {
			holder = (ViewHolder) view.getTag();
		}
			holder.image
					.setBackgroundResource(MemoryActivity.arrSocialIcon1[lstNumber
							.get(position)]);
		view.setBackgroundColor(Color.WHITE);
		view.setTag(holder);
		return view;
	}

	private static class ViewHolder {
		private ImageView image;

	}
}
